package edu.jimei.projecttachy.controller;

import edu.jimei.projecttachy.service.DataSourceService;
import edu.jimei.projecttachy.service.ReportTaskService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

record Stat(String label, String value) {}

@RestController
@RequestMapping("/api/stats")
public class DashboardController {
    @Autowired
    private DataSourceService dataSourceService;
    @Autowired
    private ReportTaskService reportTaskService;

    @GetMapping
    public List<Stat> getStats() {
        int dataSourceCount = dataSourceService.findAll().size();
        int reportCount = reportTaskService.findAll().size();
        // 其他统计项可按需扩展
        return List.of(
            new Stat("连接的数据源总数", String.valueOf(dataSourceCount)),
            new Stat("已完成的报告", String.valueOf(reportCount))
        );
    }
} 